//logs.js
const Dialog = require('../../dist/dialog/dialog');
var app = getApp()
Page({
  data: {
    navTab: ["通知", "赞与感谢", "关注"],
    currentNavtab: "0",
    isShow: true,
    list:[]
  },

  onLoad: function () {

  },
  switchTab (e) {
    this.setData({
      currentNavtab: e.currentTarget.dataset.idx
    });
  },
  onShow() {
    if(!app.state){
      Dialog({
        title: '申请',
        message: '请完善用户信息',
        showCancelButton: true,
        selector: '#zan-dialog-test'
      }).then((res) => {
        wx.navigateTo({
          url: '../userInfo/userInfo',
        })
      }).catch(err => {
        wx.reLaunch({
          url: '../discovery/discovery'
        })
      })
    }else if (app.state==1){
      Dialog({
        title: '申请',
        message: '您提交申请,请等待审核',
        selector: '#zan-dialog-test'
      }).then((res) => {
        wx.reLaunch({
          url: '../discovery/discovery'
        })
      })
    }else if (app.state==2){
      var that = this;
      wx.request({
        url: app.ipaddress+'getNotifyList',
        method: 'GET',
        data: {},
        success: function (res) {
          var list = res.data.list;
          if (list == null) {
            var toastText = '获取数据失败' + res.data.errMsg;
            wx.showToast({
              title: toastText,
              icon: '',
              duration: 2000
            });
          } else {
            console.log(list)
            that.setData({
              list: list
            });
          }
        }
      })
    }
  }
})
